# new_class.rb
# July 22, 2007
#

class EntireDataBase < ActiveRecord::Migration
  def self.up
    create_table "accounts", :force => true do |t|
      t.column "customer_id",         :integer
      t.column "billing_address_id",  :integer
      t.column "shipping_address_id", :integer
    end

    create_table "address_types", :force => true do |t|
      t.column "name",        :string
      t.column "description", :string
      t.column "code",        :integer
    end

    create_table "addresses", :force => true do |t|
      t.column "party_id",        :integer
      t.column "care_of",         :string
      t.column "street",          :string
      t.column "suite",           :string
      t.column "city",            :string
      t.column "state",           :string
      t.column "zip",             :integer
      t.column "address_type_id", :integer
    end

    create_table "container_states", :force => true do |t|
      t.column "name", :string
      t.column "code", :integer
    end

    create_table "container_types", :force => true do |t|
      t.column "name",      :string
      t.column "structure", :string
    end

    create_table "containers", :force => true do |t|
      t.column "code",               :integer
      t.column "gross_weight",       :integer, :limit => 10, :precision => 10, :scale => 0
      t.column "net_weight",         :integer, :limit => 10, :precision => 10, :scale => 0
      t.column "length_yield",       :integer
      t.column "yarn_id",            :integer
      t.column "supplier_id",        :integer
      t.column "container_type_id",  :integer
      t.column "container_state_id", :integer
      t.column "roll_id",            :integer
      t.column "loom_id",            :integer
      t.column "load_type_id",       :integer
    end

    create_table "defect_types", :force => true do |t|
      t.column "name",        :string
      t.column "description", :string
      t.column "code",        :integer
    end

    create_table "fabrics", :force => true do |t|
      t.column "style_code",      :string,  :default => "",  :null => false
      t.column "warp_yarn_id",    :integer
      t.column "weft_yarn_id",    :integer
      t.column "creel_yarn_id",   :integer
      t.column "ounces_per_yard", :float,   :default => 0.0, :null => false
      t.column "price_per_yard",  :float,   :default => 0.0, :null => false
    end

    create_table "load_types", :force => true do |t|
      t.column "name", :string
      t.column "code", :integer
    end

    create_table "loom_loads", :force => true do |t|
      t.column "roll_id",      :integer
      t.column "load_type_id", :integer
      t.column "loaded_at",    :datetime
      t.column "loom_id",      :integer
      t.column "container_id", :integer
      t.column "loaded_by_id", :integer
    end

    create_table "loom_states", :force => true do |t|
      t.column "name",        :string
      t.column "code",        :integer
      t.column "description", :string
    end

    create_table "looms", :force => true do |t|
      t.column "number",             :integer
      t.column "weft_container_id",  :integer
      t.column "warp_container_id",  :integer
      t.column "creel_container_id", :integer
      t.column "loom_state_id",      :integer
      t.column "roll_id",            :integer
      t.column "fabric_id",          :integer
      t.column "doffer_id",          :integer
    end

    create_table "packaging_types", :force => true do |t|
      t.column "name",   :string
      t.column "code",   :integer
      t.column "weight", :integer, :limit => 10, :precision => 10, :scale => 0
    end

    create_table "parties", :force => true do |t|
      t.column "type",         :string
      t.column "name",         :string
      t.column "email",        :string
      t.column "work_phone",   :string
      t.column "website",      :string
      t.column "first_name",   :string
      t.column "last_name",    :string
      t.column "mobile_phone", :string
      t.column "home_phone",   :string
    end

    create_table "roles", :force => true do |t|
      t.column "name",        :string,  :default => "", :null => false
      t.column "description", :string
      t.column "code",        :integer,                 :null => false
    end

    create_table "roles_users", :id => false, :force => true do |t|
      t.column "role_id", :integer, :null => false
      t.column "user_id", :integer, :null => false
    end

    create_table "roll_defects", :force => true do |t|
      t.column "description",    :string
      t.column "start_yard",     :integer, :limit => 10, :precision => 10, :scale => 0
      t.column "end_yard",       :integer, :limit => 10, :precision => 10, :scale => 0
      t.column "date",           :date
      t.column "roll_id",        :integer
      t.column "defect_type_id", :integer
    end

    create_table "roll_states", :force => true do |t|
      t.column "name",        :string
      t.column "code",        :integer
      t.column "description", :string
    end

    create_table "rolls", :force => true do |t|
      t.column "lot_number",        :integer
      t.column "length",            :integer
      t.column "net_weight",        :integer,  :limit => 10, :precision => 10, :scale => 0
      t.column "gross_weight",      :integer,  :limit => 10, :precision => 10, :scale => 0
      t.column "fabric_id",         :integer
      t.column "doff_date",         :datetime
      t.column "loom_id",           :integer
      t.column "roll_state_id",     :integer
      t.column "packaging_type_id", :integer
      t.column "doffed_by_id",      :integer
    end

    create_table "sessions", :force => true do |t|
      t.column "session_id", :string
      t.column "data",       :text
      t.column "updated_at", :datetime
    end

    add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
    add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"

    create_table "suppliers", :force => true do |t|
      t.column "name",     :string
      t.column "email",    :string
      t.column "phone",    :string
      t.column "street",   :string
      t.column "suite",    :string
      t.column "city",     :string
      t.column "state",    :string
      t.column "zip_code", :string
    end

    create_table "users", :force => true do |t|
      t.column "name",            :string
      t.column "hashed_password", :string
      t.column "salt",            :string
      t.column "email",           :string
      t.column "party_id",        :integer
    end

    create_table "yarns", :force => true do |t|
      t.column "name",              :string
      t.column "code",              :string
      t.column "ends",              :integer
      t.column "supplier_id",       :integer
      t.column "container_type_id", :integer
    end

  end

  def self.down
    drop_table :all
  end
end


